﻿<!DOCTYPE html>
<!--工艺介质编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .el-input__suffix {
            /* z-index: 9; */
        }

        #tcw0 .el-input__suffix {
            z-index: 10;
        }

        .el-textarea__inner {
            min-height: 98px !important;
        }

    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" size="mini">

            <!-- 区域 -->
            <el-row style="z-index: 999999;">
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="areaID">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{'区域'+mark.m}}
                                </template>
                                <treeselect v-model="Form.areaID" :options="AreaList" :flat="true" slot="suffix"
                                            style="line-height: 28px;width:70%;" :disable-branch-nodes="true"
                                            placeholder="请选择区域" />
                            </el-input>
                            <span class="iputLineMust" v-if="Form.areaID<=0 || Form.areaID==undefined">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>

            <!--要素特性-->
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="featureCharacteristics">
                            <el-input type="text" v-model="Form.featureCharacteristics" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ProcessMedium.FeatureCharacteristics+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="Form.featureCharacteristics.length<=0">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>

                <!--引导词-->
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item  prop="guideWord">
                            <el-input type="text" v-model="Form.guideWord" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ProcessMedium.GuideWord+mark.m}}
                                </template>
                            </el-input>
                            <!--<span class="iputLineMust" v-if="Form.guideWord.length<=0">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>-->
                        </el-form-item>
                    </div>
                </el-col>

                <!--偏差-->
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item   prop="deviation">
                            <el-input type="text" v-model="Form.deviation" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ProcessMedium.Deviation+mark.m}}
                                </template>
                            </el-input>
                            <!--<span class="iputLineMust" v-if="Form.deviation.length<=0">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>-->
                        </el-form-item>
                    </div>
                </el-col>

                <!--风险级别-->
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item   prop="riskLevel">
                            <el-input size="mini">
                                <template slot="prepend">
                                    <div> {{ProcessMedium.RiskLevel+mark.m}}</div>
                                </template>
                                <el-select @visible-change="visibleChange" v-model="Form.riskLevel" slot="suffix"
                                           :placeholder="ProcessMedium.RiskLevel">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in RiskLevel" :label="item.fxGrade" :value="item.id">
                                    </el-option>
                                </el-select>
                            </el-input>
                            <span class="iputLineMust" v-if="Form.riskLevel.length<=0">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <!--HSE风险-->
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item  prop="risk" >
                            <el-input type="text" v-model="Form.risk" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ProcessMedium.Risk+mark.m}}
                                </template>
                            </el-input>
                            <!--<span class="iputLineMust" v-if="Form.risk.length<=0">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>-->
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <!--危害因素-->
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item   prop="hazardousFactor">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{ProcessMedium.HazardousFactors+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.hazardousFactor"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
                <!--控制要求-->
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item   prop="controlRequirement">
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{ProcessMedium.ControlRequirement+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.controlRequirement"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click=" parent.app.ListItem.dialogVisible = false">
                        {{col.btnBack}}
                    </el-button>
                </el-form-item>
            </el-row>
        </el-form>

    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    featureCharacteristics: '',
                    guideWord: '',
                    deviation: '',
                    risk: '',
                    hazardousFactors: '',
                    controlRequirement: '',
                    riskLevel: ''
                },
                RiskLevel: [],
                AreaList: [],
                //表单验证
                rules: {
                    areaID: [
                        verification.NotNull
                    ],
                    featureCharacteristics: [
                        verification.NotNull,
                       // { pattern: verification.StringLengthAtoB.t.format(5, 50), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    guideWord: [
                        //verification.NotNull,
                        //{ pattern: verification.StringLengthAtoB.t.format(5, 50), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    deviation: [
                       // verification.NotNull,
                       // { pattern: verification.StringLengthAtoB.t.format(5, 50), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    risk: [
                       // verification.NotNull,
                        //{ pattern: verification.StringLengthAtoB.t.format(5, 100), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    riskLevel: [
                        verification.NotNull
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },

                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/FX_Process/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });

                },
                getData: function () {

                    getData(this, '/api/FX_Process/get?id=' + this.id);

                },
                GetAreaList: function (type) {
                    //alert('bbbbbb');
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: null }, offset: 0, limit: 999 }
                        , function (response) {
                            mythis.AreaList = menuHelper(response.data.pageData, guidEmpty);
                            //console.log('oooooo',mythis.AreaList);
                        },
                        false);
                },
                //初始化风险级别
                GetLevelData: function () {
                    var mythis = this;
                    myAjax("post", mythis, '/api/FX_Grade/GetListByGrade', { model: {}, offset: 0, limit: 10 }, function (response) {
                        mythis.RiskLevel = response.data.pageData
                    });
                },

                ////////////////////////////////////////////
            },
            mounted: function () {
                //this.RiskLevel = getDicData('03');
                this.id = getUrlParam("id");
                this.getData();
                this.GetAreaList();//初始化区域
                this.GetLevelData();//初始化风险级别
            }
        });

        //数据序列化(tabletree)
        function menuHelper(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>